package common;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.lib.R;

public class CommonUtils {
	/**
	 * 讀取 load 對話框
	 * @param context
	 * @param title
	 * @return
	 */
	public static AlertDialog getLoadMsg(Context context, String title) {

		final Builder builder = new Builder(context);

		LayoutInflater factory = LayoutInflater.from(context);
		View customerViewSearch = factory.inflate(R.layout.busy_bar, null);
		TextView textView = (TextView) customerViewSearch.findViewById(R.id.busyTitle);
		textView.setText(title);
		AlertDialog dialog = builder.create();

		dialog.setCanceledOnTouchOutside(false);// 不會消失
		dialog.setView(customerViewSearch);

		return dialog;
	}
	/**
	 * Show msg.
	 *
	 * @param msg the msg
	 * @param context the context
	 */
	public static void showMsg(String msg, Context context) {
		Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
	}

}
